package com.jicheng.Utils;

import com.jicheng.ext.util.MD5Utils;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * @ClassName: MD5Util
 * @Description: TODO
 * @author: khz
 * @date: 2020年09月18日 11:08
 */
public class MD5Util {
    /***
     * 对用户的密码进行MD5加密
     * 做成工具类
     */
    public static String shiroEncryption(String password) {

        // shiro 自带的工具类生成salt
        //String salt = new SecureRandomNumberGenerator().nextBytes().toString();
        String salt = "jicheng";
        // 加密次数
        int times = 1024;
        // 算法名称
        String algorithmName = "md5";

        String encodedPassword = new SimpleHash(algorithmName,password,salt,times).toString();

        // 返回加密后的密码
        return encodedPassword;
    }


    public static String convertMD5(String inStr){

        char[] a = inStr.toCharArray();
        for (int i = 0; i < a.length; i++){
            a[i] = (char) (a[i] ^ 't');
        }
        String s = new String(a);
        return s;

    }


    public static void main(String args[]){
        String s = convertMD5("14e1b600b1fd579f47433b88e8d85291");System.out.print(s);

    }
}
